home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / netzwerk / tcp-ip / netface-beta / bin / mailq.rexx < prev    next >
OS/2 REXX Batch file  |  1996-02-26  |  3KB  |  86 lines

  1.  
  2.  
  3. /* Output tuning */
  4. queue_len = 20
  5. host_len = 40
  6.  
  7. /* Make sure we have the libraries */
  8. if ~show('Libraries', 'rexxarplib.library') then
  9.         if ~addlib('rexxarplib.library', 0, -30) then do
  10.                 say "No rexxarplib, so we can't scan the spool!"
  11.                 exit
  12.                 end
  13. if ~show('Libraries', 'rexxsupport.library') then
  14.         if ~addlib('rexxsupport.library', 0, -30) then do
  15.                 say "No rexxsupport library, so we can't scan the spool!"
  16.                 exit
  17.                 end
  18.  
  19. spooldir = "UUSPOOL:"
  20. if spooldir = "" then do
  21.         say "Can't find the name of the directory to scan."
  22.         exit
  23.         end
  24. old = pragma('Directory', spooldir)
  25.  
  26. /* Get a list of files in it */
  27. count = filelist('D.???B????', files)
  28.  
  29. /* Now, process them */
  30. if count = 0 then
  31.         say "No mail waiting to go"
  32. else do
  33.         say left("Queue number", queue_len) ,
  34.                 || left("Mail Destination", host_len) || "Time in queue"
  35.         nowdays = date('Internal')
  36.         nowminutes = time('Minutes')
  37.         do i = 1 to count
  38.                 parse value files.i with 'D.???B????'queue
  39.                 parse value statef(files.i) with . . . . filedays fileminutes .
  40.                 days = nowdays - filedays     
  41.                 /* now days is day difference */
  42.                 minutes = nowminutes - fileminutes
  43.                 /* minutes is minute difference */
  44.                 if minutes < 0 then do
  45.                     /* then it's 1 less day than we think */
  46.                         days = days /*+*/- 1
  47.                         minutes = minutes + 1440
  48.                         end
  49.                 hours = 24 * days + minutes % 60
  50.                 minutes = minutes // 60
  51.                 destination = getdestination(files.i)
  52.                 if destination = "" then iterate
  53.                 out = left(i, queue_len) || left(destination, host_len)
  54.  
  55.                 select
  56.                         when hours = 0 & minutes = 0 then say out || "no time"
  57.                         when hours = 0 & minutes = 1 then say out || "1 minute"
  58.                         when hours = 0 then say out || minutes "minutes"
  59.                         when hours = 1 & minutes = 0 then say out || "1 hour"
  60.                         when hours = 1 & minutes = 1 then
  61.                                 say out || "1 hour 1 minute"
  62.                         when hours = 1 then
  63.                                 say out || "1 hour" minutes "minutes"
  64.                         when minutes = 0 then say out || hours "hours"
  65.                         when minutes = 1 then say out || hours "hours 1 minute"
  66.                         otherwise say out || hours "hours" minutes "minutes"
  67.                         end
  68.                 end
  69.         end
  70. say ""
  71. exit
  72.  
  73. getdestination: procedure
  74.         parse arg file
  75.  
  76.         if ~open(in, file, 'Read') then return ""
  77.         /* search for newsgroups line */
  78.         line = ""
  79.         do while (~eof(in)) & (left(line,3) ~= "To:")
  80.             line = readln(in)
  81.         end
  82.         call close in
  83.         return substr(line,5)
  84.  
  85. /* end of file */
  86.